import grpc
from concurrent import futures
from kea2 import kea2_pb2_grpc
from kea2.kea2_server import Kea2ControlService

def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
    kea2_pb2_grpc.add_Kea2ControlServiceServicer_to_server(
        Kea2ControlService(), server
    )
    server.add_insecure_port("[::]:50051")
    server.start()
    print("gRPC server started. Listening on :50051")
    server.wait_for_termination()

if __name__ == "__main__":
    serve()